package com.bckj.fastboot.core.extra.relational;

import jakarta.persistence.Column;
import lombok.Getter;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;

/**
 * RelationalPersistentProperty 
 *
 * @author wfc
 **/
@Getter
public class RelationalPersistentProperty extends AnnotationBasedPersistentProperty<RelationalPersistentProperty> {

    private final String columnName;

    public RelationalPersistentProperty(Property property, PersistentEntity<?, RelationalPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
        super(property, owner, simpleTypeHolder);
        if (isAnnotationPresent(Column.class)) {
            Column annotation = findAnnotation(Column.class);
            columnName = annotation.name();
        } else {
            columnName = getName();
        }
    }

    @Override
    protected Association<RelationalPersistentProperty> createAssociation() {
        return null;
    }


}
